<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateYHistoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('y_histories')) {
            Schema::create('y_histories', function (Blueprint $table) {
                $table->engine = 'MyISAM';
                $table->increments('history_id');
                $table->integer('history_user_id')->default(0)->comment('用户id');
                $table->integer('history_picture_first_id')->default(0)->comment('图片id(1）');
                $table->integer('history_picture_second_id')->default(0)->comment('图片id(2）');
                $table->integer('history_choosed_picture_id')->default(0)->comment('选择的图片id');
                $table->timestamps();

                //索引
                $table->index('history_user_id');
                $table->index('history_choosed_picture_id');
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('y_histories');
    }
}
